home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tk2.3 / dist / tkInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  17.7 KB  |  530 lines

  1. /*
  2.  * tkInt.h --
  3.  *
  4.  *    Declarations for things used internally by the Tk
  5.  *    procedures but not exported outside the module.
  6.  *
  7.  * Copyright 1990-1992 Regents of the University of California.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /user6/ouster/wish/RCS/tkInt.h,v 1.65 92/08/21 11:42:27 ouster Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _TKINT
  20. #define _TKINT
  21.  
  22. #ifndef _XLIB_H_
  23. #include <X11/Xlib.h>
  24. #endif
  25. #ifndef _XUTIL_H
  26. #include <X11/Xutil.h>
  27. #endif
  28. #ifndef _TK
  29. #include "tk.h"
  30. #endif
  31. #ifndef _TCL
  32. #include "tcl.h"
  33. #endif
  34. #ifndef _TCLHASH
  35. #include "tclHash.h"
  36. #endif
  37.  
  38. /*
  39.  * One of the following structures is maintained for each display
  40.  * containing a window managed by Tk:
  41.  */
  42.  
  43. typedef struct TkDisplay {
  44.     Display *display;        /* Xlib's info about display. */
  45.     struct TkDisplay *nextPtr;    /* Next in list of all displays. */
  46.     char *name;            /* Name of display (with any screen
  47.                  * identifier removed).  Malloc-ed. */
  48.     Time lastEventTime;        /* Time of last event received for this
  49.                  * display. */
  50.  
  51.     /*
  52.      * Information used by tkEvent.c only:
  53.      */
  54.  
  55.     struct TkWindow *mouseMainPtr;
  56.                 /* Pointer to the main window of this
  57.                  * display that currently contains the
  58.                  * mouse pointer.  NULL means the pointer
  59.                  * isn't in a main window managed by
  60.                  * this process. */
  61.  
  62.     /*
  63.      * Information used by tkBind.c only:
  64.      */
  65.  
  66.     int firstKeycode;        /* First keycode supported by
  67.                  * display. */
  68.     int lastKeycode;        /* Last keycode supported by
  69.                  * display. */
  70.     int symsPerCode;        /* Number of KeySyms in "keySyms"
  71.                  * for each keycode.  0 means the
  72.                  * keysym information hasn't been
  73.                  * retrieved from the server yet. */
  74.     KeySym *keySyms;        /* Array of KeySyms, returned by
  75.                  * XGetKeyboardMapping. */
  76.  
  77.     /*
  78.      * Information used by tkError.c only:
  79.      */
  80.  
  81.     struct TkErrorHandler *errorPtr;
  82.                 /* First in list of error handlers
  83.                  * for this display.  NULL means
  84.                  * no handlers exist at present. */
  85.     int deleteCount;        /* Counts # of handlers deleted since
  86.                  * last time inactive handlers were
  87.                  * garbage-collected.  When this number
  88.                  * gets big, handlers get cleaned up. */
  89.  
  90.     /*
  91.      * Information used by tkSend.c only:
  92.      */
  93.  
  94.     Tk_Window commWindow;    /* Window used for communication
  95.                  * between interpreters during "send"
  96.                  * commands.  NULL means send info hasn't
  97.                  * been initialized yet. */
  98.     Atom commProperty;        /* X's name for comm property. */
  99.     Atom registryProperty;    /* X's name for property containing
  100.                  * registry of interpreter names. */
  101.  
  102.     /*
  103.      * Information used by tkSelect.c only:
  104.      */
  105.  
  106.     Tk_Window selectionOwner;    /* Current owner of selection, or
  107.                  * NULL if selection isn't owned by
  108.                  * a window in this process.  */
  109.     int selectionSerial;    /* Serial number of last XSelectionSetOwner
  110.                  * request we made to server (used to
  111.                  * filter out redundant SelectionClear
  112.                  * events. */
  113.     Time selectionTime;        /* Timestamp used to acquire selection. */
  114.     Atom multipleAtom;        /* Atom for MULTIPLE.  None means
  115.                  * selection stuff isn't initialized. */
  116.     Atom incrAtom;        /* Atom for INCR. */
  117.     Atom targetsAtom;        /* Atom for TARGETS. */
  118.     Atom timestampAtom;        /* Atom for TIMESTAMP. */
  119.     Atom textAtom;        /* Atom for TEXT. */
  120.     Atom compoundTextAtom;    /* Atom for COMPOUND_TEXT. */
  121.  
  122.     /*
  123.      * Information used by tkAtom.c only:
  124.      */
  125.  
  126.     int atomInit;        /* 0 means stuff below hasn't been
  127.                  * initialized yet. */
  128.     Tcl_HashTable nameTable;    /* Maps from names to Atom's. */
  129.     Tcl_HashTable atomTable;    /* Maps from Atom's back to names. */
  130.  
  131.     /*
  132.      * Information used by tkCursor.c only:
  133.      */
  134.  
  135.     Font cursorFont;        /* Font to use for standard cursors.
  136.                  * None means font not loaded yet. */
  137.  
  138.     /*
  139.      * Information used by tkGrab.c only:
  140.      */
  141.  
  142.     struct TkWindow *grabWinPtr;
  143.                 /* Window in which the pointer is currently
  144.                  * grabbed, or NULL if none. */
  145.     struct TkWindow *ungrabWinPtr;
  146.                 /* Window to which pointer should be returned
  147.                  * when the current grab ends (i.e. the
  148.                  * window that the mouse is really on top
  149.                  * of). */
  150.     struct TkWindow *buttonWinPtr;
  151.                 /* Window in which first mouse button was
  152.                  * pressed while grab was in effect, or NULL
  153.                  * if no such press in effect. */
  154.     struct TkWindow *pointerWinPtr;
  155.                 /* The window that officially contains the
  156.                  * pointer, as far as this application is
  157.                  * concerned.  If a grab is in effect then
  158.                  * this may not be the window that's underneath
  159.                  * the pointer.  NULL means the application
  160.                  * doesn't consider the pointer to be in any
  161.                  * window. */
  162.     struct TkWindow *serverWinPtr;
  163.                 /* The window that contains the pointer, as
  164.                  * far as the X server is concerned.  This
  165.                  * field gets set on every Enter or Leave
  166.                  * event even if the grab code eventually
  167.                  * discards the event.  NULL means the server
  168.                  * thinks the pointer is outside any window
  169.                  * of any application on this screen. */
  170.     int grabFlags;        /* Miscellaneous flag values.  See definitions
  171.                  * in tkGrab.c. */
  172. } TkDisplay;
  173.  
  174. /*
  175.  * One of the following structures exists for each error handler
  176.  * created by a call to Tk_CreateErrorHandler.  The structure
  177.  * is managed by tkError.c.
  178.  */
  179.  
  180. typedef struct TkErrorHandler {
  181.     TkDisplay *dispPtr;        /* Display to which handler applies. */
  182.     unsigned long firstRequest;    /* Only errors with serial numbers
  183.                  * >= to this are considered. */
  184.     unsigned long lastRequest;    /* Only errors with serial numbers
  185.                  * <= to this are considered.  This
  186.                  * field is filled in when XUnhandle
  187.                  * is called.  -1 means XUnhandle
  188.                  * hasn't been called yet. */
  189.     int error;            /* Consider only errors with this
  190.                  * error_code (-1 means consider
  191.                  * all errors). */
  192.     int request;        /* Consider only errors with this
  193.                  * major request code (-1 means
  194.                  * consider all major codes). */
  195.     int minorCode;        /* Consider only errors with this
  196.                  * minor request code (-1 means
  197.                  * consider all minor codes). */
  198.     Tk_ErrorProc *errorProc;    /* Procedure to invoke when a matching
  199.                  * error occurs.  NULL means just ignore
  200.                  * errors. */
  201.     ClientData clientData;    /* Arbitrary value to pass to
  202.                  * errorProc. */
  203.     struct TkErrorHandler *nextPtr;
  204.                 /* Pointer to next older handler for
  205.                  * this display, or NULL for end of
  206.                  * list. */
  207. } TkErrorHandler;
  208.  
  209. /*
  210.  * One of the following structures exists for each event handler
  211.  * created by calling Tk_CreateEventHandler.  This information
  212.  * is used by tkEvent.c only.
  213.  */
  214.  
  215. typedef struct TkEventHandler {
  216.     unsigned long mask;        /* Events for which to invoke
  217.                  * proc. */
  218.     Tk_EventProc *proc;        /* Procedure to invoke when an event
  219.                  * in mask occurs. */
  220.     ClientData clientData;    /* Argument to pass to proc. */
  221.     struct TkEventHandler *nextPtr;
  222.                 /* Next in list of handlers
  223.                  * associated with window (NULL means
  224.                  * end of list). */
  225. } TkEventHandler;
  226.  
  227. /*
  228.  * One of the following structures exists for each selection
  229.  * handler created by calling Tk_CreateSelHandler.  This
  230.  * information is used by tkSelect.c only.
  231.  */
  232.  
  233. typedef struct TkSelHandler {
  234.     Atom target;        /* Target type for selection
  235.                  * conversion, such as TARGETS or
  236.                  * STRING. */
  237.     Atom format;        /* Format in which selection
  238.                  * info will be returned, such
  239.                  * as STRING or ATOM. */
  240.     Tk_SelectionProc *proc;    /* Procedure to generate selection
  241.                  * in this format. */
  242.     ClientData clientData;    /* Argument to pass to proc. */
  243.     int size;            /* Size of units returned by proc
  244.                  * (8 for STRING, 32 for almost
  245.                  * anything else). */
  246.     struct TkSelHandler *nextPtr;
  247.                 /* Next selection handler associated
  248.                  * with same window (NULL for end of
  249.                  * list). */
  250. } TkSelHandler;
  251.  
  252. /*
  253.  * Tk keeps one of the following data structures for each main
  254.  * window (created by a call to Tk_CreateMainWindow).  It stores
  255.  * information that is shared by all of the windows associated
  256.  * with a particular main window.
  257.  */
  258.  
  259. typedef struct TkMainInfo {
  260.     struct TkWindow *winPtr;    /* Pointer to main window. */
  261.     Tcl_Interp *interp;        /* Interpreter associated with application. */
  262.     Tcl_HashTable nameTable;    /* Hash table mapping path names to TkWindow
  263.                  * structs for all windows related to this
  264.                  * main window.  Managed by tkWindow.c. */
  265.     Tk_BindingTable bindingTable;
  266.                 /* Used in conjunction with "bind" command
  267.                  * to bind events to Tcl commands. */
  268.     struct TkWindow *focusPtr;    /* Identifies window that currently has the
  269.                  * focus (or that will get the focus the next
  270.                  * time the pointer enters any of the top-level
  271.                  * windows associated with this main window).
  272.                  * NULL means nobody has the focus.
  273.                  * Managed by tkEvent.c. */
  274.     struct ElArray *optionRootPtr;
  275.                 /* Top level of option hierarchy for this
  276.                  * main window.  NULL means uninitialized.
  277.                  * Managed by tkOption.c. */
  278. } TkMainInfo;
  279.  
  280. /*
  281.  * Tk keeps one of the following structures for each window.
  282.  * Some of the information (like size and location) is a shadow
  283.  * of information managed by the X server, and some is special
  284.  * information used here, such as event and geometry management
  285.  * information.  This information is (mostly) managed by tkWindow.c.
  286.  * WARNING: the declaration below must be kept consistent with the
  287.  * Tk_ClientWindow structure in tk.h.  If you change one, be sure to
  288.  * change the other!!
  289.  */
  290.  
  291. typedef struct TkWindow {
  292.  
  293.     /*
  294.      * Structural information:
  295.      */
  296.  
  297.     Display *display;        /* Display containing window. */
  298.     TkDisplay *dispPtr;        /* Tk's information about display
  299.                  * for window. */
  300.     int screenNum;        /* Index of screen for window, among all
  301.                  * those for dispPtr. */
  302.     Window window;        /* X's id for window.   NULL means window
  303.                  * hasn't actually been created yet, or it's
  304.                  * been deleted. */
  305.     struct TkWindow *childList;    /* First in list of child windows,
  306.                  * or NULL if no children. */
  307.     struct TkWindow *parentPtr;    /* Pointer to parent window (logical
  308.                  * parent, not necessarily X parent), or
  309.                  * NULL if this is a main window. */
  310.     struct TkWindow *nextPtr;    /* Next in list of children with
  311.                  * same parent (NULL if end of
  312.                  * list). */
  313.     TkMainInfo *mainPtr;    /* Information shared by all windows
  314.                  * associated with a particular main
  315.                  * window.  NULL means this window is
  316.                  * a rogue that isn't associated with
  317.                  * any application (at present, there
  318.                  * should never be any rogues).  */
  319.  
  320.     /*
  321.      * Name and type information for the window:
  322.      */
  323.  
  324.     char *pathName;        /* Path name of window (concatenation
  325.                  * of all names between this window and
  326.                  * its top-level ancestor).  This is a
  327.                  * pointer into an entry in
  328.                  * mainPtr->nameTable or NULL if mainPtr
  329.                  * is NULL. */
  330.     Tk_Uid nameUid;        /* Name of the window within its parent
  331.                  * (unique within the parent). */
  332.     Tk_Uid classUid;        /* Class of the window.  NULL means window
  333.                  * hasn't been given a class yet. */
  334.  
  335.     /*
  336.      * Geometry and other attributes of window.  This information
  337.      * may not be updated on the server immediately;  stuff that
  338.      * hasn't been reflected in the server yet is called "dirty".
  339.      * At present, information can be dirty only if the window
  340.      * hasn't yet been created.
  341.      */
  342.  
  343.     XWindowChanges changes;    /* Geometry and other info about
  344.                  * window. */
  345.     unsigned int dirtyChanges;    /* Bits indicate fields of "changes"
  346.                  * that are dirty. */
  347.     XSetWindowAttributes atts;    /* Current attributes of window. */
  348.     unsigned long dirtyAtts;    /* Bits indicate fields of "atts"
  349.                  * that are dirty. */
  350.  
  351.     unsigned int flags;        /* Various flag values:  these are all
  352.                  * defined in tk.h (confusing, but they're
  353.                  * needed there for some query macros). */
  354.  
  355.     /*
  356.      * Information kept by the event manager (tkEvent.c):
  357.      */
  358.  
  359.     TkEventHandler *handlerList;/* First in list of event handlers
  360.                  * declared for this window, or
  361.                  * NULL if none. */
  362.     /*
  363.      * Information related to input focussing (tkEvent.c):
  364.      */
  365.  
  366.     Tk_FocusProc *focusProc;    /* Procedure to invoke when this window
  367.                  * gets or loses the input focus.  NULL
  368.                  * means this window is not prepared to
  369.                  * receive the focus. */
  370.     ClientData focusData;    /* Arbitrary value to pass to focusProc. */
  371.  
  372.     /*
  373.      * Information used by tkOption.c to manage options for the
  374.      * window.
  375.      */
  376.  
  377.     int optionLevel;        /* -1 means no option information is
  378.                  * currently cached for this window.
  379.                  * Otherwise this gives the level in
  380.                  * the option stack at which info is
  381.                  * cached. */
  382.     /*
  383.      * Information used by tkSelect.c to manage the selection.
  384.      */
  385.  
  386.     TkSelHandler *selHandlerList;
  387.                 /* First in list of handlers for
  388.                  * returning the selection in various
  389.                  * forms. */
  390.     Tk_LostSelProc *selClearProc;
  391.     ClientData selClearData;    /* Info to pass to selClearProc. */
  392.  
  393.     /*
  394.      * Information used by tkGeometry.c for geometry management.
  395.      */
  396.  
  397.     Tk_GeometryProc *geomProc;    /* Procedure to handle geometry
  398.                  * requests (NULL means no window is
  399.                  * unmanaged). */
  400.     ClientData geomData;    /* Argument for geomProc. */
  401.     int reqWidth, reqHeight;    /* Arguments from last call to
  402.                  * Tk_GeometryRequest, or 0's if
  403.                  * Tk_GeometryRequest hasn't been
  404.                  * called. */
  405.     int internalBorderWidth;    /* Width of internal border of window
  406.                  * (0 means no internal border).  Geom.
  407.                  * mgr. should not place children on top
  408.                  * of the border. */
  409.  
  410.     /*
  411.      * Information maintained by tkWm.c for window manager communication.
  412.      */
  413.  
  414.     struct TkWmInfo *wmInfoPtr;    /* For top-level windows, points to
  415.                  * structure with wm-related info (see
  416.                  * tkWm.c).  For other windows, this
  417.                  * is NULL. */
  418. } TkWindow;
  419.  
  420. /*
  421.  * The context below is used to map from an X window id to
  422.  * the TkWindow structure associated with the window.
  423.  */
  424.  
  425. extern XContext tkWindowContext;
  426.  
  427. /*
  428.  * Pointer to first entry in list of all displays currently known.
  429.  */
  430.  
  431. extern TkDisplay *tkDisplayList;
  432.  
  433. /*
  434.  * Flags passed to TkMeasureChars:
  435.  */
  436.  
  437. #define TK_WHOLE_WORDS        1
  438. #define TK_AT_LEAST_ONE        2
  439. #define TK_PARTIAL_OK        4
  440. #define TK_NEWLINES_NOT_SPECIAL    8
  441.  
  442. /*
  443.  * Location of library directory containing Tk scripts.  This value
  444.  * is put in the $tkLibrary variable for each application.
  445.  */
  446.  
  447. #ifndef TK_LIBRARY
  448. #define TK_LIBRARY "/usr/local/lib/tk"
  449. #endif
  450.  
  451. /*
  452.  * See tkShare.c for explanation of following disgusting variable:
  453.  */
  454.  
  455. extern XEvent *tkShareEventPtr;
  456.  
  457. /*
  458.  * Miscellaneous variables shared among Tk modules but not exported
  459.  * to the outside world:
  460.  */
  461.  
  462. extern Tk_Uid        tkActiveUid;
  463. extern Tk_Uid        tkDisabledUid;
  464. extern Tk_Uid        tkNormalUid;
  465.  
  466. /*
  467.  * Internal procedures shared among Tk modules but not exported
  468.  * to the outside world:
  469.  */
  470.  
  471. extern int        TkAreaToPolygon _ANSI_ARGS_((double *polyPtr,
  472.                 int numPoints, double *rectPtr));
  473. extern void        TkBezierPoints _ANSI_ARGS_((double control[],
  474.                 int numSteps, double *coordPtr));
  475. extern void        TkBindError _ANSI_ARGS_((Tcl_Interp *interp));
  476. extern void        TkBindEventProc _ANSI_ARGS_((TkWindow *winPtr,
  477.                 XEvent *eventPtr));
  478. extern Time        TkCurrentTime _ANSI_ARGS_((TkDisplay *dispPtr));
  479. extern int        TkDeadAppCmd _ANSI_ARGS_((ClientData clientData,
  480.                 Tcl_Interp *interp, int argc, char **argv));
  481. extern void        TkDisplayChars _ANSI_ARGS_((Display *display,
  482.                 Drawable drawable, GC gc,
  483.                 XFontStruct *fontStructPtr, char *string,
  484.                 int numChars, int x, int y, int flags));
  485. extern void        TkEventDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
  486. extern void        TkFocusEventProc _ANSI_ARGS_((TkWindow *winPtr,
  487.                 XEvent *eventPtr));
  488. extern void        TkGetButtPoints _ANSI_ARGS_((double p1[], double p2[],
  489.                 double width, int project, double m1[],
  490.                 double m2[]));
  491. extern int        TkGetInterpNames _ANSI_ARGS_((Tcl_Interp *interp,
  492.                 Tk_Window tkwin));
  493. extern int        TkGetMiterPoints _ANSI_ARGS_((double p1[], double p2[],
  494.                 double p3[], double width, double m1[],
  495.                 double m2[]));
  496. extern void        TkGrabDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
  497. extern int        TkLineToArea _ANSI_ARGS_((double end1Ptr[2],
  498.                 double end2Ptr[2], double rectPtr[4]));
  499. extern double        TkLineToPoint _ANSI_ARGS_((double end1Ptr[2],
  500.                 double end2Ptr[2], double pointPtr[2]));
  501. extern int        TkMeasureChars _ANSI_ARGS_((XFontStruct *fontStructPtr,
  502.                 char *source, int maxChars, int startX, int maxX,
  503.                 int flags, int *nextXPtr));
  504. extern void        TkOptionDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
  505. extern int        TkOvalToArea _ANSI_ARGS_((double *ovalPtr,
  506.                 double *rectPtr));
  507. extern double        TkOvalToPoint _ANSI_ARGS_((double ovalPtr[4],
  508.                 double width, int filled, double pointPtr[2]));
  509. extern int        TkPointerEvent _ANSI_ARGS_((XEvent *eventPtr,
  510.                 TkWindow *winPtr));
  511. extern int        TkPolygonToArea _ANSI_ARGS_((double *polyPtr,
  512.                 int numPoints, double *rectPtr));
  513. extern double        TkPolygonToPoint _ANSI_ARGS_((double *polyPtr,
  514.                 int numPoints, double *pointPtr));
  515. extern void        TkSelDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
  516. extern void        TkSelEventProc _ANSI_ARGS_((Tk_Window tkwin,
  517.                 XEvent *eventPtr));
  518. extern void        TkSelPropProc _ANSI_ARGS_((XEvent *eventPtr));
  519. extern void        TkUnderlineChars _ANSI_ARGS_((Display *display,
  520.                 Drawable drawable, GC gc,
  521.                 XFontStruct *fontStructPtr, char *string,
  522.                 int x, int y, int flags, int firstChar,
  523.                 int lastChar));
  524. extern void        TkWmDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
  525. extern int        TkWmMapWindow _ANSI_ARGS_((TkWindow *winPtr));
  526. extern void        TkWmSetClass _ANSI_ARGS_((TkWindow *winPtr));
  527. extern void        TkWmNewWindow _ANSI_ARGS_((TkWindow *winPtr));
  528.  
  529. #endif  /* _TKINT */
  530.